Tressaweb::Application.routes.draw do

  devise_for :users,  :controllers => { :sessions => "user_sessions", :registrations => 'admin/registrations' },
             :path_names => {:sign_in => 'login', :sign_out => 'logout', :registration => 'register'}

  devise_scope :user do
    get "sign_in", :to => "devise/sessions#new"
    get "sign_up", :to => "admin/registrations#new"
  end

  resources :home
  resources :products

  #resources :registrations

  # Products
  match '/products/filter' => 'products#filter_products', :as => :filter_products
  match '/products/add_to_cart' => 'products#add_to_cart', :as => :add_to_cart
  match '/admin/products/import' => 'admin/products#import_products', :as => :admin_import_products
  match '/admin/search_products' => 'admin/products#search', :as => :admin_product_search
  match '/admin/sold_out/:product_id' => 'admin/products#sold_out', :as => :admin_sold_out_product
  match '/admin/update_sold_out/:product_id' => 'admin/products#update_sold_out', :as => :admin_update_sold_out_product
  match '/admin/toggle_display/:product_id' => 'admin/products#toggle_display', :as => :admin_toggle_product

  # Cart
  match '/cart' => 'products#show_cart', :as => :show_cart
  match '/cart/remove_item/:item_id' => 'products#remove_from_cart', :as => :remove_product_from_cart
  match '/empty_cart' => 'products#empty_cart', :as => :empty_cart
  match '/change_item_quantity' => 'products#change_item_quantity', :as => :change_item_quantity_cart

  # Orders
  match '/orders/success' => 'orders#success_message', :as => :show_order_success_message
  match '/admin/orders/:id/process' => 'admin/orders#mark_as_processed', :as => :admin_process_order

  # General
  match '/admin' => 'admin/dashboard#index'
  match '/search' => 'products#search', :as => :search

  # Clients
  match '/my_orders' => 'clients/orders#index', :as => :client_orders
  match '/my_info' => 'clients/profiles#edit', :as => :client_info
  match '/update_info/:id' => 'clients/profiles#update', :as => :clients_client
  match '/admin/search_clients' => 'admin/clients#search', :as => :admin_client_search

  # Categories
  match '/admin/categories/change_order' => 'admin/categories#change_order', :as => :change_categories_order
  match '/admin/categories/update_order' => 'admin/categories#update_order', :as => :update_categories_order

  # Slides
  match '/admin/slide_images/change_order' => 'admin/slide_images#change_order', :as => :change_slides_order
  match '/admin/slide_images/update_order' => 'admin/slide_images#update_order', :as => :update_slides_order

  # Misc
  match '/contact' => 'home#contact', :as => :contact
  match '/submit_contact' => 'home#submit_contact_form', :as => :submit_contact_form
  match '/successful_contact' => 'home#successful_contact', :as => :successful_contact
  match '/technical_service' => 'home#technical_service', :as => :technical_service
  match '/about' => 'home#about', :as => :about

  resources :orders

  namespace :admin do
    resources :dashboard
    resources :categories
    resources :products
    resources :clients
    resources :orders
    resources :slide_images

    root :to => "dashboard#index"
  end

  namespace :clients do
    resources :orders
    resources :profiles
  end

  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  root :to => "home#index"

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
end
